package 实验2;

public class Student extends people {
	String major;
	String hobby;
	public Student() {
		super();
		courses = new Course[3];
		}
	public Student(int stuId,String stuName,String stuSex,String major,String hobby) {
		super();
		this.id=stuId;
	    this.Name=stuName;
	    this.major = major;
	    this.hobby = hobby;
	    this.sex=stuSex;
	    courses = new Course[3];
	    }
	public Student(int stuId,String stuName,String major) {
		super();
	    this.id=stuId;
	    this.Name=stuName;
	    this.major = major;
	    courses = new Course[3];
	    }
	public Student(int stuId,String stuName) {
		super();
		this.id = stuId;
	    this.Name = stuName;
	    courses = new Course[3];
	    }
	public String getStuName() {
		return Name;
		}
	public void setStuName(String stuName) {
	    this.Name = stuName;
	    }
	public int getStuId() {
	    return id;
	    }
	public void setStuId(int stuId) {
	    this.id = stuId;
	    }
	public String getMajor() {
	    return major;
	    }
	public void setMajor(String major) {
	    this.major = major;
	    }
    public String getStuSex() {
	    return sex;
	    }
	public void setStuSex(String stuSex) {
	    this.sex = stuSex;
	    }
	public boolean addCourse(Course course){
		boolean flag=false;
		if(!isSelectedCourse(course)&&isNullCourse(course)){
			for(int i=0;i<this.courses.length;i++){
				if(courses[i]==null){
					courses[i]=course;
					course.addStudent(this);
					flag=true;
					break;
					}
				}
			return flag;
			}
		return flag;
		}
	 private boolean isNullCourse(Course course) {

		return false;
	}
	private boolean isSelectedCourse(Course course) {
		return false;
	}
	public boolean removeCourse(Course course){
		boolean flag=false;
		if(isSelectedCourse(course)){
			for(int i=0;i<this.courses.length;i++){
				if(courses[i]==course){
					courses[i]=null;
					course.removeStudent(this);
					flag=true;
					break;
					}
				}
		return flag;
		}
		return flag;
	}

	public void displayCourse(){
		System.out.println("学生"+this.Name+this.id+this.sex+this.major+"所选课程有：");
		for(Course c:courses){
			if(c!=null){
				System.out.print(c.getName());
				}
			}
		}
	}